/*
 * MappedPropertyChangeEvent.java
 *
 * Created on Dec 10, 2007 at 6:30:45 PM
 *
 * Copyright 2008 the Desert Labs Project (http://desertlabs.us)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package us.desertlabs.beans;

import java.beans.PropertyChangeEvent;

/**
 * A <CODE>MappedPropertyChangeEvent</CODE> can be delivered when a component that
 * conforms to the JavaBeans<TM> specification (a "bean") changes a bound
 * property that is a <CODE>Map</CODE>. This class is an extension of <CODE>PropertyChangeEvent</CODE>
 * but contains the map key of the property value that has changed.
 * <P>
 * Null values may be provided for the old and the new values if their
 * true values are not known.
 * <P>
 * An event source may send a null object as the name to indicate that an
 * arbitrary set of if its properties have changed.  In this case the
 * old and new values should also be null.
 *
 * @author Brandon Franklin
 */
public class MappedPropertyChangeEvent extends PropertyChangeEvent {

    /** */
    private static final long serialVersionUID = 2094649413411301620L;

    /** The key of the property value that was changed */
    private final Object key;

    /**
     * Constructs a new <CODE>MappedPropertyChangeEvent</CODE> object.
     *
     * @param source the bean that fired the event
     * @param propertyName the programmatic name of the property that was changed
     * @param oldValue the old value of the property
     * @param newValue the new value of the property
     * @param key the key of the property value that was changed
     */
    public MappedPropertyChangeEvent( final Object source, final String propertyName,
            final Object oldValue, final Object newValue,
            final Object key ) {
        super( source, propertyName, oldValue, newValue );
        this.key = key;
    }

    /**
     * Gets the key of the property value that was changed.
     *
     * @return the key of the the property value that was changed
     */
    public Object getKey() {
        return key;
    }
}

